package com.neu.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * DI值实体类
 */
@Schema(description = "DI值实体")
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("di") // 数据库表名
public class FpDIValue {

    @Schema(description = "DI值ID")
    @TableId(type = IdType.ASSIGN_ID) // 指定主键生成
    private int did;

    @Schema(description = "任务ID")
    private String taskId;

    @Schema(description = "第一项值")
    private int fir;

    @Schema(description = "第二项值")
    private int sec;

    @Schema(description = "第三项值")
    private int thi;

    @Schema(description = "第四项值")
    private int fou;

    @Schema(description = "第五项值")
    private int fif;

    @Schema(description = "第六项值")
    private int six;

    @Schema(description = "第七项值")
    private int sen;

    @Schema(description = "第八项值")
    private int eig;

    @Schema(description = "第九项值")
    private int nin;

    @Schema(description = "第十项值")
    private int ten;

    @Schema(description = "第十一项值")
    private int ele;

    @Schema(description = "第十二项值")
    private int twe;

    @Schema(description = "第十三项值")
    private int thirteenth;

    @Schema(description = "第十四项值")
    private int fourteenth;

    public int calDI() {
        return fir + sec + thi + fou + fif + six + sen + eig + nin + ten + ele + twe + thirteenth + fourteenth;
    }
    public float calVAF() {
        // 调用 calDI 方法计算 DI 的总和
        int totalDI = calDI();
        // 根据公式计算 VAF，并强制转换为 float
        return (float) ((totalDI * 0.01) + 0.65);
    }
}
